package gui;


import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import constants.Cmd;

public class DeleteChooserFrame extends JFrame implements ActionListener{
	private JButton delete;
	private JPanel buttons, centerPanel;
	private JTextField patientNamn;
	private JLabel patientNamnL;
	private GUIControl gc;
	public DeleteChooserFrame(GUIControl gc){
		this.gc=gc;
		this.setTitle("Patient Deleter");
		this.setLayout(new BorderLayout());
		centerPanel=new JPanel();
		buttons=new JPanel();
		this.add(centerPanel, BorderLayout.CENTER);
		this.add(buttons, BorderLayout.PAGE_END);
		delete=new JButton("Delete");
		buttons.add(delete);
		delete.addActionListener(this);
		patientNamnL=new JLabel("Patient: ");
		centerPanel.add(patientNamnL);
		patientNamn=new JTextField();
		patientNamn.setPreferredSize(new Dimension(180,25));
		centerPanel.add(patientNamn);
		centerPanel.setPreferredSize(new Dimension(250,35));
		this.pack();
	}
	public void clear(){
		patientNamn.setText("");
	}
	public void actionPerformed(ActionEvent arg0) {
		if(arg0.getActionCommand()=="Delete"){
			gc.sendToServer(Cmd.delete+patientNamn.getText());
			this.setVisible(false);
			this.clear();
		}
	}
}
